package in.falkeninc.umt_v0_9_8_1;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

class SpinnerCustomAdapter extends ArrayAdapter<String>  {

    String[] objects;
	Context context; 

    public SpinnerCustomAdapter(Context context, int textViewResourceId,   String[] objects) {
        super(context, textViewResourceId, objects);
        this.objects = objects;
        this.context = context;
    }
    
    @Override
    public View getDropDownView(int position, View convertView,ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    public View getCustomView(int position, View convertView, ViewGroup parent) {

    	LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

    	View row=inflater.inflate(R.layout.row, parent, false);
 
        ImageView icon = (ImageView)row.findViewById(R.id.icon);

        TypedArray imgs = context.getResources().obtainTypedArray(R.array.minusIcons);
        
        icon.setImageResource(imgs.getResourceId(position, -1));        
        
        imgs.recycle();
        
        return row;
     }
}    
